public class wordline {
    public static void main(String[] args) {
        String str = "hello china";
        int index = str.lastIndexOf(" ");
        String w = str.substring(index+1);
        int lenth = w.length();
        System.out.printf("最后一个单词长度为%d",lenth);
    }
}
